package  
{
	import flash.events.MouseEvent;
	import flash.text.TextFormat;
	import style.TextStyle;
	/**
	 * ...
	 * @author ...
	 */
	public class MMLinkButton extends MMInteractive 
	{
		private const DEFAULT_OVER_STYLE:TextStyle = new TextStyle(new TextFormat("宋体", 12, 0x0000FF));
		private const DEFAULT_NORMAL_STYLE:TextStyle = new TextStyle(new TextFormat("宋体", 12, 0x0000FF));
		
		private var _uiLabel:MMLabel;
		private var _normalStyle:TextStyle;
		private var _overStyle:TextStyle;
		private var _underline:Boolean;
		
		private var _label:String;
		
		
		public function MMLinkButton() 
		{
			_normalStyle = DEFAULT_NORMAL_STYLE;
			_overStyle = DEFAULT_OVER_STYLE;
			buttonMode = true;
			mouseChildren = false;
		}
		
		override public function onInit():void
		{
			super.onInit();
			_uiLabel = new MMLabel();
			_uiLabel.textStyle = normalStyle;
			_uiLabel.show();
			addChild(_uiLabel);
			onMouseOver = mouseOverHandler;
			onMouseOut = mouseOutHandler;
			onMouseDown = mouseDownHandler;
		}
		
		private function mouseDownHandler(e:MouseEvent):void 
		{
			
		}
		
		private function mouseOutHandler(e:MouseEvent):void 
		{
			_uiLabel.textStyle = _normalStyle;
		
		}
		
		private function mouseOverHandler(e:MouseEvent):void 
		{
			_uiLabel.textStyle = _overStyle;
		}
		
		override public function onHide():void
		{
			super.onHide();
		}
		
		override public function onShow():void
		{
			super.onShow();
			update();
		}
		
		override public function updateData():void
		{
			super.updateData();
			_uiLabel.text = _label;
			
		}
		
		public function get underline():Boolean { return _underline; }
		
		public function set underline(value:Boolean):void 
		{
			_underline = value;
			if (value)
			{
				_overStyle.textFormat.underline = true;
				_normalStyle.textFormat.underline = false;
			}
			else
			{
				_overStyle.textFormat.underline = false;
				_normalStyle.textFormat.underline = true;
			}
		}
		
		public function get normalStyle():TextStyle { return _normalStyle; }
		
		public function set normalStyle(value:TextStyle):void 
		{
			_normalStyle = value;
			
		}
		
		public function get overStyle():TextStyle { return _overStyle; }
		
		public function set overStyle(value:TextStyle):void 
		{
			_overStyle = value;
			
		}
		
		public function get label():String { return _label; }
		
		public function set label(value:String):void 
		{
			_label = value;
			update();
		}
		
		
		
	}

}